﻿
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>6.Cookie配置</title>
    <script type="text/javascript" src="../Content/highlighter/scripts/shCore.js"></script>
    <script type="text/javascript" src="../Content/highlighter/scripts/shBrushCSharp.js"></script>
    <script type="text/javascript" src="../Content/highlighter/scripts/shBrushXml.js"></script>
    <link type="text/css" rel="stylesheet" href="../Content/highlighter/styles/shCoreDefault.css"/>
    <script type="text/javascript">SyntaxHighlighter.all();</script>
</head>
<body>
    <h3>Cookie配置</h3>
    1.在[模块名]/Code/Data/CookieInfo.cs中定义你的Cookie变量
    <pre class="brush: csharp;">
        public class CookieInfo
        {
            public string name="";
            public bool islogin=false;
            public int age=0;
        }
    </pre>
    2.运行WebCompiler.aspx生成[模块名]/Code/Data/CookieManager.cs类<br />
    3.在Controllers中读取和使用cookie:
    <pre class="brush: csharp;">
        public void Index()
        {
            //让Cookie操作变得更简单.
            Cookie.name="NFinal";
            Write(_cookies.age);
        }
    </pre>
	<p>
		此方式的好处有3：<br/>
		1.便于Cookie统一管理。<br/>
		2.方便使用，不用去特意记忆Cookie名称，只需按.就会有自动提示。<br/>
		3.当调用Web层下的Action类生成静态页时，只需把cookie作为参数填进去即可。<br/>
	</p>
</body>
</html>
